﻿/// -----------------------------------------------------------------------
/// (c) 2009 Microsoft Corporation -- All rights reserved
/// This code is licensed under the MS-PL
/// http://www.opensource.org/licenses/ms-pl.html
/// Courtesy of the Open Source Techology Center: http://port25.technet.com
/// -----------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using gsToolkit;

namespace mkProject {
    public class SourceFile {
        private string _fileName;
        public string fileName {
            set {

                _fileName = value;
                if( MakeProject.App.ProjectRoot.IsSubPath(value) ) {
                    subDir = Path.GetFullPath(value).Substring(MakeProject.App.ProjectRoot.Length);
                    // trim off any leading slashes
                    while(subDir.IndexOf("\\") == 0) {
                        subDir = subDir.Substring(1);
                    }

                    // trim off everything up to the last slash.
                    while(subDir.Length > 0 && subDir[subDir.Length-1] != '\\' ) {
                        subDir = subDir.Substring(0,subDir.Length - 1);
                    }

                    // then trim off the last slashes
                    while(subDir.Length > 0 && subDir[subDir.Length-1] == '\\')
                        subDir = subDir.Substring(0, subDir.Length - 1);
                }
                else {
                    subDir = "";
                }

            }
            get {
                return _fileName;
            }
        }
        public List<string> includes { set; get; }
        public List<string> defines { set; get; }
        public string targetOutput = "";
        public string outputPath = "";
        public string outputFile = "";
        public string subDir = "";

    }
}
